<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="!crud.props.searchToggle">
        <el-form size="small" label-width="70px">
          <el-row :gutter="10">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="客户名称">
                <el-input></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="客户id" prop="customerId">
            <el-input v-model="form.customerId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="充值活动id" prop="rechargeId">
            <el-input v-model="form.rechargeId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="客户编码" prop="customerCode">
            <el-input v-model="form.customerCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="客户名称" prop="customerName">
            <el-input v-model="form.customerName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="充值活动编码" prop="rechargeCode">
            <el-input v-model="form.rechargeCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="系统订单号">
            <el-input v-model="form.outTradeNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收款单编码">
            <el-input v-model="form.receiptCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="充值金额">
            <el-input v-model="form.rechargeAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="抵扣金额">
            <el-input v-model="form.deductionAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="充值人">
            <el-input v-model="form.createUserName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="充值时间">
            <el-input v-model="form.createTime" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" stripe border v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column type="index" width="55" label="序号"/>
        <el-table-column v-if="columns.visible('customerCode')" prop="customerCode" label="客户编码" />
        <el-table-column v-if="columns.visible('customerName')" prop="customerName" label="客户名称" />
        <el-table-column v-if="columns.visible('rechargeCode')" prop="rechargeCode" label="充值活动编码" />
        <el-table-column v-if="columns.visible('outTradeNo')" prop="outTradeNo" label="系统订单号" />
        <el-table-column v-if="columns.visible('receiptCode')" prop="receiptCode" label="收款单编码" />
        <el-table-column v-if="columns.visible('rechargeAmount')" prop="rechargeAmount" label="充值金额" />
        <el-table-column v-if="columns.visible('deductionAmount')" prop="deductionAmount" label="抵扣金额" />
        <el-table-column v-if="columns.visible('createUserName')" prop="createUserName" label="充值人" />
        <el-table-column v-if="columns.visible('createTime')" prop="createTime" label="充值时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-permission="['admin','activeCustomerRechargeRecord:edit','activeCustomerRechargeRecord:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudActiveCustomerRechargeRecord from '@/api/erp/activeCustomerRechargeRecord'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

// crud交由presenter持有
const defaultCrud = CRUD({ title: '客户充值记录', url: 'api/activeCustomerRechargeRecord', sort: 'id,desc', crudMethod: { ...crudActiveCustomerRechargeRecord }})
const defaultForm = { id: null, customerId: null, rechargeId: null, outTradeNo: null, createUserId: null, createTime: null }
export default {
  name: 'ActiveCustomerRechargeRecord',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  data() {
    return {

      permission: {
        add: ['admin', 'activeCustomerRechargeRecord:add'],
        edit: ['admin', 'activeCustomerRechargeRecord:edit'],
        del: ['admin', 'activeCustomerRechargeRecord:del'],
        import: ['admin', 'activeCustomerRechargeRecord:import'],
        export: ['admin', 'activeCustomerRechargeRecord:export'],
        copy: ['admin', 'activeCustomerRechargeRecord:copy'],
        upload: ['admin', 'activeCustomerRechargeRecord:upload'],
        download: ['admin', 'activeCustomerRechargeRecord:download'],
      },
      rules: {
        customerId: [
          { required: true, message: '客户id不能为空', trigger: 'blur' }
        ],
        rechargeId: [
          { required: true, message: '充值活动id不能为空', trigger: 'blur' }
        ]
      }    }
  },
  watch: {
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },

  }
}
</script>

<style scoped>
  .table-img {
    display: inline-block;
    text-align: center;
    background: #ccc;
    color: #fff;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    vertical-align: middle;
    width: 32px;
    height: 32px;
    line-height: 32px;
  }
</style>
